package jpa.repository;

import jpa.entity.Person;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

/**
 * Created by barton on 16-4-29.
 */
public interface PersonRepository extends JpaRepository<Person, Long>, CrudRepository<Person,
        Long> {
    @Query("select count(p.firstName) from Person p where firstName like %?1")
    Long countByLastNameEndsWith(String firstName);

    Person findByLastName(String lastName);

    List<Person> findByLastNameOrderByFirstNameDesc(String lastName);

    List<Person> findByAddress_ZipCode(String zipCode);

    List<Person> findFirst5ByLastName(String lastName, Sort sort);

//    NoOrderItem findByFirstName(String firstName);
}
